package com.inspur.edp.common.expr.util;

/**
 * @author lizhaorui
 * @date 2025/11/18
 * @description
 */
public class DSLStringUtils {

    public static String handle(String str) {
        if (str == null) {
            return null;
        }
        char[] chars = str.toCharArray();
        StringBuilder sb = new StringBuilder();
        for (char c : chars) {
            if (c == '"') {
                sb.append("\\");
                sb.append(c);
            } else if (c == '\n') {
                sb.append("\\n");
            } else if (c == '\b') {
                sb.append("\\b");
            } else if (c == '\t') {
                sb.append("\\t");
            } else {
                sb.append(c);
            }
        }
        return sb.toString();
    }

}